local skel = fk.CreateSkill{
  name = "lb__huojin",
}

Fk:loadTranslationTable{
  ["lb__huojin"] = "霍金",
  --[":lb__huojin"] = "出牌阶段限一次，或当你受到伤害后，你可以令一名角色声明一种颜色，其摸一张牌并展示之，然后其重复此流程直到摸到声明颜色的牌。",
  --9.7
  [":lb__huojin"] = "每回合各限一次，出牌阶段或当你受到伤害后，你可以令一名角色声明一种颜色，其摸一张牌并展示之，然后其重复此流程直到摸到声明颜色的牌。",

  ["#lb__huojin"] = "霍金：你可以令一名角色声明一种颜色，其摸一张牌并展示之，然后其重复此流程直到摸到声明颜色的牌",
  ["#lb__huojin_ask"] = "霍金：请声明一种颜色，你摸一张牌并展示之，重复此流程直到摸到声明颜色的牌",

  ["$lb__huojin1"] = "幸运儿会是哪个呢？",
  ["$lb__huojin2"] = "啊呀呀，这就是追星之旅嘛？",
  ["$lb__huojin3"] = "猜猜我要干什么？",
}
---@param to ServerPlayer 
local huojin_draw = function (to)
  local room = to.room
  local color = room:askToChoice(to, {
    choices = {"red", "black"},
    skill_name = skel.name,
    prompt = "#lb__huojin_ask",
  })
  room:sendLog{
    type = "#Choice",
    from = to.id,
    arg = color,
    toast = true,
  }
  local color_int = (color == "red" and 2 or 1)
  repeat
    local id = to:drawCards(1, skel.name)[1]
    room:showCards(id)
    room:delay(150)
  until Fk:getCardById(id).color == color_int
end

skel:addEffect("active", {
  anim_type = "drawcard",
  prompt = "#lb__huojin",
  max_turn_use_time = 1,
  can_use = function (self, player)
    --return player:usedSkillTimes(skel.name, Player.HistoryPhase) < 1
    return player.phase == Player.Play
  end,
  card_filter = Util.FalseFunc,
  target_filter = function (self, player, to_select, selected, selected_cards, card, extra_data)
    return #selected == 0
  end,
  feasible = function (self, player, selected, selected_cards, card)
    return #selected == 1
  end,
  on_use = function (self, room, skillUseEvent)
    huojin_draw(skillUseEvent.tos[1])
  end,
}, { check_effect_limit = true })

skel:addEffect(fk.Damaged, {
  max_turn_use_time = 1,
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local tos = room:askToChoosePlayers(player, {
      targets = room:getAlivePlayers(),
      min_num = 1,
      max_num = 1,
      skill_name = skel.name,
      cancelable = true,
      prompt = "#lb__huojin",
    })
    if #tos > 0 then
      event:setCostData(self, {tos = tos})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    huojin_draw(event:getCostData(self).tos[1])
  end,
}, { check_effect_limit = true })

return skel